import { defineStore } from "pinia";
import { ref } from "vue";
import { userLogin } from "../api/user";

export const useAccount = defineStore('user',()=>{
    const userInfo = ref(null) //存储用户信息
    const loginAsync = async ({username,password})=>{
        let res = await userLogin({username,password})
        console.log('状态机登录',res);
        if(res.type=='success'){
            userInfo.value = res.data
        }
        return res
    }
    return {userInfo,loginAsync}
},{persist:true})